

using System;

namespace NodeBasedSkillEditor.Model.Node.RT
{
    public class Node_Power_RT : RT_Node
    {
        public RT_SingleValuePort Base_RT;

        public RT_SingleValuePort Exponent_RT;

        public RT_SingleValuePort Power_RT;

        public Node_Power_RT(Node_Power sourceData, RT_DAG parentDag) : base(sourceData, parentDag)
        {
            Base_RT = new RT_SingleValuePort(EPortIOType.Input, sourceData.Base, this);

            Exponent_RT = new RT_SingleValuePort(EPortIOType.Input, sourceData.Exponent, this);

            Power_RT = new RT_SingleValuePort(EPortIOType.Output, sourceData.Power, this);
            Power_RT.OnGetValue = GetPower;
        }

        public AValue GetPower(DAG_Executor executor)
        {
            float baseV = Base_RT.GetValue(executor).ToScalar().Item2;
            float expV = Exponent_RT.GetValue(executor).ToScalar().Item2;
            float power = MathF.Pow(baseV, expV);
            Power_RT.SourceValue.SetScalar(power);
            return Power_RT.SourceValue;
        }
    }
}